package com.education.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 管理员操作日志表
 *
 * @author education-platform
 * @since 2024-09-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("audit_log")
@JsonIgnoreProperties(value = {"handler"})
public class AuditLog {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 管理员ID
     */
    @TableField("admin_id")
    private Long adminId;

    /**
     * 操作类型
     */
    @TableField("action")
    private String action;

    /**
     * 操作对象类型
     */
    @TableField("target_type")
    private String targetType;

    /**
     * 操作对象ID
     */
    @TableField("target_id")
    private Long targetId;

    /**
     * 操作前的值
     */
    @TableField("old_value")
    private String oldValue;

    /**
     * 操作后的值
     */
    @TableField("new_value")
    private String newValue;

    /**
     * 操作备注
     */
    @TableField("remark")
    private String remark;

    /**
     * IP地址
     */
    @TableField("ip")
    private String ip;

    /**
     * 用户代理
     */
    @TableField("user_agent")
    private String userAgent;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    // 关联对象（用于XML映射）
    @TableField(exist = false)
    private User admin;
}

